package com.betterjr.modules.supplieroffer.dubbo;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;

import com.alibaba.dubbo.config.annotation.Service;
import com.betterjr.common.web.AjaxObject;
import com.betterjr.modules.rule.service.RuleServiceDubboFilterInvoker;
import com.betterjr.modules.supplieroffer.IScfSupplierOfferService;
import com.betterjr.modules.supplieroffer.entity.ScfSupplierOffer;
import com.betterjr.modules.supplieroffer.service.ScfSupplierOfferService;

@Service(interfaceClass = IScfSupplierOfferService.class)
public class ScfSupplierOfferDubboService implements IScfSupplierOfferService {

    @Autowired
    private ScfSupplierOfferService offerService;

    @Override
    public String webSaveAddOffer(Map<String, Object> anMap) {

        final ScfSupplierOffer offer = RuleServiceDubboFilterInvoker.getInputObj();
        return AjaxObject.newOk("供应商利率新增成功", offerService.saveAddSupplierOffer(offer)).toJson();
    }

    @Override
    public String webSaveUpdateOffer(Long anCustNo, Long anCoreCustNo, double anCoreCustRate) {

        return AjaxObject
                .newOk("供应商利率修改成功", offerService.saveUpdateSupplierOffer(anCustNo, anCoreCustNo, anCoreCustRate))
                .toJson();
    }

    @Override
    public String webQueryOfferPage(Map<String, Object> anMap, String anFlag, int anPageNum, int anPageSize) {

        return AjaxObject.newOkWithPage("供应商利率查询成功",
                offerService.queryScfSupplierOfferPage(anMap, anFlag, anPageNum, anPageSize)).toJson();
    }

    @Override
    public String webFindOffer(Long anCustNo, Long anCoreCustNo) {

        return AjaxObject.newOk("供应商利率查询成功", offerService.findOffer(anCustNo, anCoreCustNo)).toJson();
    }

    @Override
    public String webFindOffer(Long anId) {

        return AjaxObject.newOk("供应商利率查询成功", offerService.selectByPrimaryKey(anId)).toJson();
    }

    @Override
    public String webQueryAllCust(Long anCoreCustNo) {

        return AjaxObject.newOk("查询供应商成功", offerService.queryAllCust(anCoreCustNo)).toJson();
    }

    @Override
    public String webQueryAllFactoryByCustNo(Long anCustNo) {

        return AjaxObject.newOk("查询成功", offerService.queryAllFactoryByCustNo(anCustNo)).toJson();
    }

    /**
     * 
     * <p>Overriding Method of webStatisticQueryOfferList</p>  
     * <p>Description: </p> 
     * @param anMap
     * @return 
     * @see com.betterjr.modules.supplieroffer.IScfSupplierOfferService#webStatisticQueryOfferList(java.util.Map) 
     * @author chenlq
     * @date 2017年11月27日 下午4:06:56
     */
    @Override
    public String webStatisticQueryOfferList(Map<String, Object> anMap) {

        return AjaxObject.newOk("供应商利率查询成功", offerService.queryStatisticQueryOfferList(anMap)).toJson();
    }

}
